﻿<ipnut type="hidden" id="MenuNo" value="Menus" />
<div id="layout">
    <div position="left" id="mainmenu" title="菜单操作">
        <ul id="tree">
        </ul>
    </div>
    <div id="list" position="center" />
</div>
<ul class="iconlist">
</ul>
@section footer{
    <script type="text/javascript">
        var columns = [{ hide: true, display: '菜单编号', name: 'Id' }
                , { display: '菜单名', name: 'ModuleName', align: 'left', width: 150, minWidth: 60, editor: { type: 'text'} }
                , { display: '控制器', name: 'ModuleController', align: 'left', width: 150, minWidth: 60, editor: { type: 'text'} }
                , { display: '排序号', name: 'Sort', align: 'left', width: 150, minWidth: 60, editor: { type: 'int'} }
        ];

        var toolbaritems = [
                  { id: "C", text: '添加', click: toolbarclick, img: '@Url.Content("~/Content/icons/silkicons/add.png")' }
                , { line: true }
                , { id: "U", text: '修改', click: toolbarclick, img: '@Url.Content("~/Content/icons/silkicons/edit.png")' }
                , { line: true }
                , { id: "D", text: '删除', click: toolbarclick, img: '@Url.Content("~/Content/icons/silkicons/delete.png")' }
            ];

        function toolbarclick(item) {
            switch (item.id) {
                case "C":
                    child = $.ligerDialog.open({ width: 600, height: 300, url: '@Url.Action("Create")', showMax: true, showToggle: true, showMin: true, isResize: true, modal: true, title: '菜单新增' });
                    break;
                case "U":
                    var rows = grid.getSelected();
                    if (!rows) { $.ligerDialog.warn('请选择行!'); return }
                    child = $.ligerDialog.open({ width: 600, height: 300, url: '@Url.Action("Update")' + '?keys=' + rows.Id.toString(), showMax: true, showToggle: true, showMin: true, isResize: true, modal: true, title: '菜单修改' });
                    break;
                case "D":
                    var rows = grid.getSelecteds();
                    if (rows.length == 0) { $.ligerDialog.warn('请选择行!'); return }
                    $.ligerDialog.confirm("确认删除吗", function (r) {
                        if (r) {
                            LG.gridpost('@Url.Action("Delete")', { data: JSON.stringify(rows) }, grid);
                        }
                    });
                    break;
            }
        }

        $(function () {
            $("#layout").ligerLayout({ leftWidth: 140 });
            $("#tree").ligerTree({
                url: '@Url.Action("GetTree")',
                checkbox: false,
                onClick: function (node) {
                    parentid = node.data.id;
                    grid = $("#list").ligerGrid({
                        url: '@Url.Action("GetGrid")' + '?p=' + parentid, columns: columns, dataAction: 'server', pageSize: 20, sortName: "Sort", sortOrder: 'asc',
                        rownumbers: true, width: '98%', height: '100%', heightDiff: -10, checkbox: false, toolbar: {}
                    });
                    grid.toolbarManager.set("items", toolbaritems);
                }
            });
        });
    </script>
}
